package main;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * the class that displays the player's resources
 * @author Bart
 *no param
 */
public class ResourcePanel extends JFrame {
	JPanel pane = new JPanel();
	int[] resArray;
/**
 * default constructor
 * @param t the turnmangager for the current game
 */
	public ResourcePanel(final TurnManager t) {
		super(t.active.getName() +" Resources");
		
		JLabel info = new JLabel("Crash course on resources: more is better");
		resArray = t.active.getRes().getArray();

		JLabel wood = new JLabel("Wood: " +resArray[0]);
		JLabel metal = new JLabel("Metal: " +resArray[1]);
		JLabel food = new JLabel("Food: " +resArray[2]);
		JLabel hap = new JLabel("Happiness: " +resArray[3]);
		JLabel res = new JLabel("Research: " +resArray[4]);
		JLabel bluPoints = new JLabel("Your points: " +t.active.getRes().getScore().getScore());
		JLabel redPoints = new JLabel("Enemy points: " +t.inactive.getRes().getScore().getScore());

		BoxLayout bl = new BoxLayout(pane, BoxLayout.PAGE_AXIS);

		pane.setLayout(bl);
		pane.add(info);
		pane.add(Box.createVerticalGlue());
		pane.add(wood);
		pane.add(metal);
		pane.add(food);
		pane.add(hap);
		pane.add(res);
		pane.add(Box.createVerticalGlue());
		pane.add(bluPoints);
		pane.add(redPoints);
		
		this.add(pane);
		this.setVisible(true);
		this.setSize(300, 150);

		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				t.active.resPane = false;
			}
		});

	}
}
